﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    assembly="KuaJing.Organization"
    namespace="KuaJing.Organization.Domain">

    <class name="Position" table="Organization_Position">
        <id name="Id" access="field.camelcase"
            column="PositionId" type="Int32">
            <generator class="native" />
        </id>
      <version name="Version" access="field.camelcase" />
        <property name="Name" />
        <property name="ShortName" />
        <many-to-one name="Company" column="CompanyId" foreign-key="FK_OrganizationUnit_OrganizationUnitId_Organization_EmployeeId" class="KuaJing.Organization.Domain.OrganizationUnit" cascade="save-update" />
        <property name="Reserve" />
      

      <many-to-one name="Role" column="RoleId" foreign-key="FK_Security_RoleId" 
                   class="KuaJing.Security.Domain.Role,KuaJing.Security" cascade="save-update" />

      <set name="Organizations"  table="Organization_OrganizationUnit_Position" inverse="false"  cascade="all" >
        <key column="PositionId" foreign-key="FK_Organization_Position_PositionId_Organization_OrganizationUnit_OrganizationId"></key>
        <many-to-many class="OrganizationUnit" column="OrganizationId"></many-to-many>
      </set>
      
      <set name="Employees"  table="Organization_Position_Employee" inverse="true"  cascade="save-update" >
        <key column="PositionId" foreign-key="FK_Organization_Employee_EmployeeId_Organization_Position_PositionId"></key>
        <many-to-many class="Employee" column="EmployeeId"></many-to-many>
      </set>
     
    <property name="CreatedTime" access="field.camelcase" />
    <property name="CreatedUserName" access="field.camelcase" />
    <property name="ModifiedTime" access="field.camelcase" />
    <property name="ModifiedUserName" access="field.camelcase" />
    <property name="AccessedTime" access="field.camelcase" />
    <property name="AccessedUserName" access="field.camelcase" />
    <property name="Memo" />
    <property name="IsInvalid" />
    </class>
</hibernate-mapping>
